﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;

/// <summary>
/// Summary description for ShoppingCart
/// </summary>

namespace LinqObj
{
    public partial class Service
    {

        private EntityRef<Service_Category> _Category;
        [Association(Storage = "_Category", OtherKey = "service_category_id",
        ThisKey = "service_category_id", IsForeignKey = true)]
        public Service_Category Cateogry
        {
            get
            {
                return this._Category.Entity;
            }
        }
    }
}
//        #region
//        private string serviceName;
//        private decimal servcieCharge;
//        private int standardServiceDays;
//        private int serviceID;
//        private static string iconHomeDir;
//        private int categoryID;
//        private string serviceDes;
//        private int supplierID;
//        #endregion

//        #region
//        public string ServiceName { get { return this.serviceName; } }
//        public static string IconHomeDir { get { return Service.iconHomeDir; } set { Service.iconHomeDir = value; } }
//        public decimal ServcieCharge { get { return this.servcieCharge; } set { this.servcieCharge = value; } }
//        public int ServiceID { get { return this.serviceID; } }
//        public int CategoryID { get { return this.categoryID; } }
//        public string ServiceDes { get { return this.serviceDes; } set { this.serviceDes = value; } }
//        public int SupplierID { get { return this.supplierID; } set { this.supplierID = value; } }
//        #endregion

//        public Service()
//        {
//            Service.iconHomeDir = @"image/thumb_nails";
//        }

//        public static IEnumerable<Service> LoadServiceList(IDbConnection conn, string agentGroupID)
//        {
//            return LoadServiceList(conn, Convert.ToInt32(agentGroupID));
//        }

//        public static IEnumerable<Service> LoadServiceList(IDbConnection conn, int agentGroupID)
//        {
//            string sql_script =
//                                @"select service_id, service_name,
//                                service_charge, service_category_id, service_description, supplier_id
//                                from service where service_id in (select service_id from Service_AgentGroup_Index where agent_group_id = {0})";
//            sql_script = String.Format(sql_script, agentGroupID.ToString());

//            IDbCommand cmd = conn.CreateCommand();
//            cmd.CommandText = sql_script;
//            IDataReader dr = cmd.ExecuteReader();
//            List<Service> serviceList = new List<Service>();
//            while (dr.Read())
//            {
//                Service tmp = new Service();
//                tmp.serviceID = dr.GetInt32(0);
//                tmp.serviceName = dr.GetString(1);
//                tmp.servcieCharge = dr.GetDecimal(2);
//                tmp.categoryID = dr.GetInt32(3);
//                tmp.serviceDes = dr.GetString(4);
//                serviceList.Add(tmp);
//            }
//            return serviceList;
//        }

